package com.zhoukx.factory.simplefactory.pizzastore.order;

import com.zhoukx.factory.simplefactory.pizzastore.pizza.CheesePizza;
import com.zhoukx.factory.simplefactory.pizzastore.pizza.GreekPizza;
import com.zhoukx.factory.simplefactory.pizzastore.pizza.Pizza;

/**
 * @ClassName SimpleFactory
 * @Description: 工厂类   简单工厂类
 * @Author zhoukx
 * @Date 2020/8/6
 **/
public class SimpleFactory {
    public Pizza createPizza(String orderType){
        System.out.println("使用简单工厂模式");

        Pizza pizza = null;
        if (orderType.equals("greek")) {
            pizza = new GreekPizza();
        }else  if (orderType.equals("cheese")){
            pizza = new CheesePizza();
        }else  if (orderType.equals("pepper")){
            pizza = new CheesePizza();
        }
        return pizza;
    }

    // 简单工厂模式，也叫静态工厂模式
    public static Pizza createPizza2(String orderType){
        System.out.println("使用简单工厂模式2");

        Pizza pizza = null;
        if (orderType.equals("greek")) {
            pizza = new GreekPizza();
        }else  if (orderType.equals("cheese")){
            pizza = new CheesePizza();
        }else  if (orderType.equals("pepper")){
            pizza = new CheesePizza();
        }
        return pizza;
    }
}
